package com.skywolf.chem.common.sysconfig.pojo.vo;

/**
 * Created by pei_pei on 2020/10/27.
 */

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;

public class PageVO<T> {
    @ApiModelProperty(
            value = "当前页",
            required = true,
            example = "1"
    )
    public Long pageNum;
    @ApiModelProperty(
            value = "每页的数量",
            required = true,
            example = "20"
    )
    public Long pageSize;
    @ApiModelProperty(
            value = "总记录数",
            required = true,
            example = "200"
    )
    public Long total = Long.valueOf(0L);
    @ApiModelProperty(
            value = "总页数",
            required = true,
            example = "10"
    )
    public Long pages = Long.valueOf(0L);
    @ApiModelProperty(
            value = "数据集合",
            required = true
    )
    public List<T> list;

    public PageVO(IPage<T> page) {
        this.setPageNum(Long.valueOf(page.getCurrent()));
        this.setPageSize(Long.valueOf(page.getSize()));
        this.setTotal(Long.valueOf(page.getTotal()));
        this.setPages(Long.valueOf(page.getPages()));
        this.setList(page.getRecords());
    }

    public PageVO(List<T> list, long total, long pages, long pageNum, long pageSize) {
        this.setList(list);
        this.setPageNum(Long.valueOf(pageNum));
        this.setPages(Long.valueOf(pages));
        this.setTotal(Long.valueOf(total));
        this.setPageSize(Long.valueOf(pageSize));
    }

    public PageVO() {
    }

    public PageVO(List<T> list, long total, long pageNum, long pageSize) {
        this.setList(list);
        this.setPageNum(Long.valueOf(pageNum));
        this.setPages(Long.valueOf((total + pageSize - 1L) / pageSize));
        this.setTotal(Long.valueOf(total));
        this.setPageSize(Long.valueOf(pageSize));
    }


    public Long getPageNum() {
        return this.pageNum;
    }

    public Long getPageSize() {
        return this.pageSize;
    }

    public Long getTotal() {
        return this.total;
    }

    public Long getPages() {
        return this.pages;
    }

    public List<T> getList() {
        return this.list;
    }

    public void setPageNum(Long pageNum) {
        this.pageNum = pageNum;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public void setPages(Long pages) {
        this.pages = pages;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public boolean equals(Object o) {
        if(o == this) {
            return true;
        } else if(!(o instanceof PageVO)) {
            return false;
        } else {
            PageVO other = (PageVO)o;
            if(!other.canEqual(this)) {
                return false;
            } else {
                label71: {
                    Long this$pageNum = this.getPageNum();
                    Long other$pageNum = other.getPageNum();
                    if(this$pageNum == null) {
                        if(other$pageNum == null) {
                            break label71;
                        }
                    } else if(this$pageNum.equals(other$pageNum)) {
                        break label71;
                    }

                    return false;
                }

                Long this$pageSize = this.getPageSize();
                Long other$pageSize = other.getPageSize();
                if(this$pageSize == null) {
                    if(other$pageSize != null) {
                        return false;
                    }
                } else if(!this$pageSize.equals(other$pageSize)) {
                    return false;
                }

                label57: {
                    Long this$total = this.getTotal();
                    Long other$total = other.getTotal();
                    if(this$total == null) {
                        if(other$total == null) {
                            break label57;
                        }
                    } else if(this$total.equals(other$total)) {
                        break label57;
                    }

                    return false;
                }

                Long this$pages = this.getPages();
                Long other$pages = other.getPages();
                if(this$pages == null) {
                    if(other$pages != null) {
                        return false;
                    }
                } else if(!this$pages.equals(other$pages)) {
                    return false;
                }

                List this$list = this.getList();
                List other$list = other.getList();
                if(this$list == null) {
                    if(other$list == null) {
                        return true;
                    }
                } else if(this$list.equals(other$list)) {
                    return true;
                }

                return false;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof PageVO;
    }

    public int hashCode() {
        boolean PRIME = true;
        byte result = 1;
        Long $pageNum = this.getPageNum();
        int result1 = result * 59 + ($pageNum == null?43:$pageNum.hashCode());
        Long $pageSize = this.getPageSize();
        result1 = result1 * 59 + ($pageSize == null?43:$pageSize.hashCode());
        Long $total = this.getTotal();
        result1 = result1 * 59 + ($total == null?43:$total.hashCode());
        Long $pages = this.getPages();
        result1 = result1 * 59 + ($pages == null?43:$pages.hashCode());
        List $list = this.getList();
        result1 = result1 * 59 + ($list == null?43:$list.hashCode());
        return result1;
    }

    public String toString() {
        return "PageVO(pageNum=" + this.getPageNum() + ", pageSize=" + this.getPageSize() + ", total=" + this.getTotal() + ", pages=" + this.getPages() + ", list=" + this.getList() + ")";
    }
}
